package book;

public class Book {
    public String name;
    public String id;
    public int num;
    public String writer;
    public String type;
    public int hot;

    public int getHot() {
        return hot;
    }

    public void setHot(int hot) {
        this.hot = hot;
    }

    public Book(String name, String id, int num, String writer, String type, int hot) {
        this.name = name;
        this.id = id;
        this.num = num;
        this.writer = writer;
        this.type = type;
        this.hot = hot;
    }

    public Book() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "Book{" +
                "书名='" + name + '\'' +
                ", 书号='" + id + '\'' +
                ", 余量=" + num +
                ", 作者='" + writer + '\'' +
                ", 类型='" + type + '\'' +
                ", 热度='" + hot + '\'' +
                '}';
    }
    //根据(书号)进行排序
    public int compareToid(Book book) {
        return Integer.valueOf(this.id) - Integer.valueOf(book.id);
    }
    //根据(热度)进行排序
    public int compareTohot(Book book){
        return book.hot - this.hot;
    }
}
